console.log('===>', $event)
const widgets = this.getApiPage().getApiWidgetByAliasName('三维组件');
const form144 = this.pageObj.getApiWidgetByAliasName('form_144')
const change = this.getApiPage().getApiWidgetByAliasName('change')?.widgetObj;
let camera = { ...$event }

function playCamera (camera) {
    const equipmentUnifyConfig = camera?.equipmentConfig?.equipmentUnifyConfig
    if (equipmentUnifyConfig) {
        const { onlineStatus } = equipmentUnifyConfig
        if (+onlineStatus !== 0) {
            return window.layer?.msg('摄像头未找到配置！');
        } else {

        }
    }
}


if (widgets) {
    console.log(widgets)
    if (camera.deviceId && camera.channelId) {


        const id = $event.equipmentCode
        change._option.defaultKey = 'preset'
        change.render()
        _form.setFormData('form_14', { id })
        const options = {
            method: 'POST',
            headers: {
                "Content-type": "application/json",
            },
            body: JSON.stringify({ equipmentId: $event.equipmentCode })
        }
        fetch('/IotDdevice/project-business-iot-service/hikvision/sdk/queryPresets', options)
            .then(res => res.json())
            .then(json => {
                if (json.success) {
                    console.log('_form', _form)
                    const list = json.result.map(v => ({
                        ...v,
                        sourceName: v.name,
                        name: v.presetNum + '-' + v.name,
                        value: v.presetNum
                    }))
                    $form.widgetObj._option.options = {
                        list
                    }
                    this.pageObj.setVariables([{ name: 'device_list', value: list }])
                    $form.widgetObj.render()
                    console.log('data', _form.getFormData('form_14'))
                } else {
                    window.layer?.msg('获取预置位失败！')
                    $form.widgetObj._option.options = { list: [] }
                    $form.widgetObj.render()
                }
                _form.setFormData('form_14', { id })
            })

    } else {
        window.layer?.msg('摄像头未找到配置！');
    }

} else {
    window.layer?.msg('摄像头未找到！');
}
